package demo1;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Demo1 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        /**
         *1、优点直接方便
         */
        Person p=new Person();
        p.sayHello();
        /**
         *反射
         */
        Class cls=Class.forName("demo1.Person");
        Person p1=(Person)cls.newInstance();
        p1.sayHello();

        //Spring容器
        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext("demo1");
        Person p2=context.getBean(Person.class);
        p.sayHello();



    }
}
